package com.gmail.bogatyr.alexander.client.view;

import com.gmail.bogatyr.alexander.client.presenter.TelephoneBookEditPresenter;
import com.gmail.bogatyr.alexander.client.presenter.TelephoneBookListPresenter;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.user.client.ui.*;

public class TelephoneBookEditWidget extends Composite implements TelephoneBookEditPresenter.Display {

    private final Panel panel;
    private final Label titleLabel;
    private final Label numberLabel;
    private final TextBox numberField;
    private final Label numberErrorLabel;
    private final Label nameLabel;
    private final TextBox nameField;
    private final Label nameErrorLabel;
    private final Button saveButton;
    private final Button cancelButton;
    
    public TelephoneBookEditWidget() {
        panel = new FlowPanel();
        initWidget(panel);
        
        titleLabel = new Label("Telephone Book");
        panel.add(titleLabel);
        
        numberLabel = new Label("Number");
        panel.add(numberLabel);
        
        numberField = new TextBox();
        numberField.setMaxLength(11);
        numberField.setFocus(true);
        panel.add(numberField);

        numberErrorLabel = new Label();
        panel.add(numberErrorLabel);
        
        nameLabel = new Label("Name");
        panel.add(nameLabel);
        
        nameField = new TextBox();
        nameField.setMaxLength(64);
        panel.add(nameField);

        nameErrorLabel = new Label();
        panel.add(nameErrorLabel);
        
        saveButton = new Button();
        panel.add(saveButton);

        cancelButton = new Button();
        panel.add(cancelButton);
    }

    @Override
    public Label getTitleLabel() {
        return titleLabel;
    }

    @Override
    public HasValue<String> getNumberTextField() {
        return numberField;
    }

    @Override
    public HasValue<String> getNameTextField() {
        return nameField;
    }

    @Override
    public HasClickHandlers getSaveButton() {
        return saveButton;
    }

    @Override
    public HasClickHandlers getCancelButton() {
        return cancelButton;
    }
}
